{template 'web/common/header'}
<style>
    .trans_msg
{
	filter:alpha(opacity=100,enabled=1) revealTrans(duration=.2,transition=1) blendtrans(duration=.2);
}

.tipimg{
    border: 0;
    width: 48px;
    height: 48px;
    padding: 2px;
}

.layui-table-cell{line-height: 50px;height: 50px;}
</style>

<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <span class="layui-breadcrumb" style="visibility: visible;">
                            <a>商品</a><span lay-separator="">/</span>
                            <a><cite>商品列表</cite></a>
                        </span>
                    </div>
                    <div class="layui-card-body">
                        <table class="layui-hide" id="goods-list-table-toolbar" lay-filter="goods-list-table-toolbar"></table>

                        <script type="text/html" id="goods-list-table-toolbar-toolbar">
                            <div class="layui-btn-container">
                                <button class="layui-btn layui-btn-sm" id="add_goods">添加商品</button>
                                <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">导入商品</button>
                            </div>
                        </script>

                        <script type="text/html" id="goods-list-table-toolbar-bar">
                              <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                              <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="../addons/xn_erp/images/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../addons/xn_erp/images/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'layer', 'jquery', 'element', 'flow','form'], function () {
            var table = layui.table, layer = layui.layer, $ = layui.$, element = layui.element, form = layui.form;
            tables = table.render({
                elem: '#goods-list-table-toolbar'
                , url: "{$url}&api=list"
                , toolbar: '#goods-list-table-toolbar-toolbar'
                , title: '商品列表'
                , cols: [[
                    { type: 'checkbox'}
                    , { field: 'img_index', title: '主图', align: "center", width: 80, style: "padding: 0px;margin: 0px;" }
                    , { field: 'number', title: '商品编码', sort: true, minWidth: 100, hide: true }
                    , { field: 'name', title: '商品名称', minWidth: 150 }
                    , { field: 'spec', title: '商品规格' , minWidth: 100,hide: true }
                    , { field: 'sale_price', title: '市场价',minWidth: 100, sort: true }
                    , { field: 'unit_cost', title: '成本价', minWidth: 100,sort: true }
                    , { field: 'location_num', title: '库存数量',minWidth: 100, sort: true }
                    , { field: 'unit_name', title: '单位' ,minWidth: 100}
                    , { field: 'status', title: '状态' ,minWidth: 100}
                    , { field: 'category_name', title: '商品分类' ,minWidth: 100}
                    , { field: 'sort', title: '排序值', width: 80,minWidth: 100, sort: true }
                    , { field: 'addtime', title: '新增时间',minWidth: 100, sort: true }
                    , { field: 'edittime', title: '修改时间',minWidth: 100, sort: true }
                    , { fixed: 'right', title: '操作', toolbar: '#goods-list-table-toolbar-bar',minWidth: 120 }
                ]]
                , page: true
                , limit: 20
            });

            table.on('checkbox(goods-list-table-toolbar)',function(obj){
                console.log(obj);
            });

            $('#add_goods').on('click', function () {
                parent.layui.index.openTabsPage('index.php?c=site&a=entry&do=goods&m=xn_erp&op=add', '添加商品');
            });

        });
    </script>
</body>
<script src="../addons/xn_erp/images/ToolTip.js"></script>

</html>